package edu.zut.oop;

/**
 * 对象数组：
 * 数组：一组具有相同类型的数据
 * 对象：属于数据，如果多个对象属于一个类型，就可以构成一个对象数组
 *
 */
public class ObjectArray {

    public static void main(String[] args) {
        //多个学生，如果统一保存
        Student student = new Student();
        student.assign("jack","2021001",20);
        Student student2 = new Student();
        student2.assign("tom","2021002",20);
        Student student3 = new Student();
        student3.assign("rose","2021003",20);

        //对象数组   默认值，每个元素是null
        Student[] students = new Student[30];
        students[0] = student;
        students[1] = student2;
        students[2] = student3;

        students[0].introduce();
        //空指针异常：对象地址为null
//        students[3].introduce();

    }


}
